package com.example.demo;

import com.mybatisflex.core.audit.AuditManager;
import com.mybatisflex.core.audit.ConsoleMessageCollector;
import com.mybatisflex.core.audit.MessageCollector;
import com.mybatisflex.core.mybatis.Mappers;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.table.TableInfoFactory;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@MapperScan
@SpringBootApplication
public class Demo7Application {

    public static void main(String[] args) {
        final ConfigurableApplicationContext context = SpringApplication.run(Demo7Application.class, args);
        //开启审计功能
        AuditManager.setAuditEnable(true);

//设置 SQL 审计收集器
        MessageCollector collector = new ConsoleMessageCollector();
        AuditManager.setMessageCollector(collector);
        final PersonMapper mapper =(PersonMapper) Mappers.ofEntityClass(Person.class);

        final Person selectPerson = mapper.selectOneById(1L);

        System.out.println(selectPerson);
    }

}
